<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div>
    <el-form ref="form" :model="s_firm" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 岗位名称 </span>
      </div>
      <el-table :data="s_firm">
        <el-table-column label="岗位名" prop="firm_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/mes/produce/PerList?category_id='+scope.row.firm_id+''+vueparams+'')" type='primary'>{{scope.row.firm_name}}</el-link>
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 人员列表 </span>
      </div>
      <el-table :data="person_info">
        <el-table-column label="" prop="user_id" width="8,8">
          <template slot-scope="scope">
            <el-checkbox-group>
              <el-checkbox v-for="dict in s_work_person" :key="dict.__code" :label="dict.__code">{{dict.__desc}}</el-checkbox>
            </el-checkbox-group>
          </template>
        </el-table-column>
        <el-table-column label="人员名称" prop="person_name">
        </el-table-column>
        <el-table-column label="公司" prop="firm_name">
        </el-table-column>
        <el-table-column label="岗位" prop="role">
        </el-table-column>
        <el-table-column label="上级领导" prop="uname">
        </el-table-column>
        <el-table-column label="手机号码" prop="relation_tel">
        </el-table-column>
        <el-table-column label="Email" prop="relation_email">
        </el-table-column>
      </el-table>
      <el-button @click="perListSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="$parent.$parent.popPerList('&category_id='+cate.firm_higher+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回上级</el-button>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'PerList',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        s_firm: [],
        person_info: [],
        s_work_person: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/produce/MftResourceAction/perList?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      perListSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/produce/MftResourceAction/perListSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.$router.replace("/redirect" + this.$route.fullPath);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
